// component/navigation/navigation.js
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    data:{
      type: Object,
      // 数据类型
      value:{}
      // 数据值
    }
  },

  /**
   * 组件的初始数据
   */
  data: {
    imgUrl:getApp().globalData.imgUrl,
    sliderData:[]
  },
  attached: function(){
    let itemDTOList = this.properties.data.itemDTOList
    let disposeList = []
    let disposeList1 = []
    let sliderData = [{disposeList:[]}]
    for (var i = 0; i < itemDTOList.length; i++) {
     if (i <= 4) {
      disposeList.push(itemDTOList[i])
      sliderData[0]['disposeList']=disposeList
     } 
     if (i > 4) {
      sliderData = [{disposeList:disposeList}, {disposeList:[]}]
      disposeList1.push(itemDTOList[i])
      sliderData[1]['disposeList']=disposeList1
     }
    }
    console.log('sliderData', sliderData)
    this.setData({
      sliderData:sliderData
    })
  },

  /**
   * 组件的方法列表
   */
  methods: {
    browsePage(e) {
      console.log('e', e)
      let linkType = e.currentTarget.dataset.data.linkType
      let linkAppId =  e.currentTarget.dataset.data.linkAppId
      let linkUrl = e.currentTarget.dataset.data.linkUrl
      let contentType = e.currentTarget.dataset.data.contentType
      if (linkType == 'otherMiniProgram') { // 其他小程序跳转
        this.goMeita(linkAppId)
      } else if (linkType == 'miniPage') {
        wx.navigateTo({
          url: linkUrl+'?isLink=true'
        })
      } else if(linkType == 'h5' && linkUrl!== '/packagBuy/pages/found/crmweb/index') {
        wx.navigateTo({
          url: '/packagBuy/pages/marketing/poster/posterh5/posterh5?h5Url=' + linkUrl
        })
      } else if(linkUrl == '/packagBuy/pages/found/crmweb/index') {
        wx.navigateTo({
          url: '/packagBuy/pages/found/crmweb/index'
        })
      }
    },
      // 美搭小程序跳转
      goMeita(linkAppId) {
      wx.navigateToMiniProgram({
        appId: linkAppId,//小程序appid
        path: '',//跳转关联小程序app.json配置里面的地址
        extraData: {
          foo: 'bar'
        },
      //**重点**要打开的小程序版本，有效值 develop（开发版），trial（体验版），release（正式版）
        envVersion: 'release',
        success(res) {
          // 打开成功
        }
      })
    },
  }
})
